package com.retailcloud.inventoryservice.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.retailcloud.commonutils.dto.ProductSearchVo;
import com.retailcloud.commonutils.dto.ProductionInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.retailcloud.inventoryservice.entity.ProductInfoEntity;
import com.retailcloud.inventoryservice.service.ProductInfoService;
import com.retailcloud.commonutils.utils.PageUtils;
import com.retailcloud.commonutils.utils.R;

import javax.servlet.http.HttpServletRequest;


/**
 * 商品信息表
 *
 * @author wudi
 * @email 632132852@qq.com
 * @date 2024-11-05 21:41:03
 */
@RestController
@RequestMapping("/productinfo")
public class ProductInfoController {
    @Autowired
    private ProductInfoService productInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions(":productinfo:list")
    public R list(@RequestBody ProductSearchVo productSearchVo){
        //PageUtils page = productInfoService.queryPage(params);
        return R.ok().put("data", productInfoService.queryPage(productSearchVo));
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions(":productinfo:info")
    public R info(@PathVariable("id") String id){
		ProductInfoEntity productInfo = productInfoService.getById(id);

        return R.ok().put("productInfo", productInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions(":productinfo:save")
    public R save(@RequestBody ProductionInfoVo productionInfoVo){
		productInfoService.saveProductInfo(productionInfoVo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions(":productinfo:update")
    public R update(@RequestBody ProductInfoEntity productInfo){
		productInfoService.updateById(productInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions(":productinfo:delete")
    public R delete(@RequestBody String[] ids){
		productInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
